from django.shortcuts import render_to_response
from django.template import RequestContext as RC

def render_to(template, processor):
    def render(func):
        def wrapper(request, *args, **kwargs):
            output = func(request, *args, **kwargs)
            if not isinstance(output, dict):
                return output
            tmpl = output.pop('TEMPLATE', template)
            return render_to_response(tmpl, output, context_instance=RC(request, processors=[processor]))
        return wrapper
    return render